package com.coffee.wakeonlan.dao;

import java.util.List;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import com.coffee.wakeonlan.entity.Machine;

public interface  MachineDao extends CrudRepository<Machine, Long>{
	Machine findByMac(String mac);
	List<Machine> findByUserId(Long userId);
	@Modifying
	@Query("update Machine set isAlive = false,ip='',osType='',hostName='' ")
	void offlineAll();
	
	@Query("from Machine where mac in(:macs)")
	List<Machine> findByMacs(@Param("macs")List<String> macs);
}
